import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * @creationDate 2019/12/25
 */
import request from "../../utils/request";
import { getEnvConfig } from "../../utils/iocUtils";
import { getResponse } from "../../utils/utils";

var _getEnvConfig = getEnvConfig(),
    CPAAS_PLATFORM = _getEnvConfig.CPAAS_PLATFORM;
/**
 * 获取加密公钥
 */


export function getPublicKey() {
  return _getPublicKey.apply(this, arguments);
}

function _getPublicKey() {
  _getPublicKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
    var res;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            res = request("".concat(CPAAS_PLATFORM, "/v1/tool/pass/public-key"), {
              method: 'GET'
            }); // FIXME: @WJC utils need fix
            // @ts-ignore

            return _context.abrupt("return", getResponse(res));

          case 2:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _getPublicKey.apply(this, arguments);
}